{extend name="main/index" /}
{block name="main"}
<style type="text/css">
    .form-group .col-xs-10{
        width:200px; 
        height:40px; 
        line-height:40px; 
        border:1px solid #CCC; 
    }
    .form-group .default{
       width:200px; 
        height:32px; 
        line-height:32px; 
        color:#999;
    }
    .form-group .error{
        height:32px; 
        line-height:32px; 
        color:#F00; 
    }
    .form-group .success{
        height:32px; 
        line-height:32px; 
        color:#096; 
    }
</style>
<div class="main-content">

    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="{:url('admin/service/index')}">劳务信息</a>
            </li>
            <li class="active">劳务申请</li>
        </ul><!-- .breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
                    <i class="icon-search nav-search-icon"></i>
                </span>
            </form>
        </div><!-- #nav-search -->
    </div>
    <div class="page-content">
        <h3 class="header smaller lighter blue">劳务申请</h3>
        <div class="col-xs-12">
            <form class="form-horizontal" action="{:url('admin/service/doadd')}" onSubmit="return checkForm()">
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 项目名称: </label>

                    <div class="col-sm-9">
                        <input type="text" name="project_name" class="col-xs-10 col-sm-5" id="project_name" onBlur="checkUserName()" oninput="checkUserName()"/>
                        <span class="default" id="nameErr"></span> 
                    </div>
                </div>
                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">劳务队名称: </label>

                    <div class="col-sm-9">
                        <input type="text" name="service_team_name" class="col-xs-10 col-sm-5" id="team" onBlur="checkteam()" oninput="checkteam()"/>
                        <span class="default" id="teamErr"></span> 
                    </div>
                </div>

                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">劳务队人数: </label>

                    <div class="col-sm-9">
                        <input type="text" name="user_num" class="col-xs-10 col-sm-5" id="num" onBlur="checknum()" oninput="checknum()"/>
                        <span class="default" id="numErr"></span> 
                    </div>
                </div>

                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">特种人员数量: </label>

                    <div class="col-sm-9">
                        <input type="text" name="special_personnel_num" class="col-xs-10 col-sm-5" id="special" onBlur="checkspecial()" oninput="checkspecial()"/>
                        <span class="default" id="specialErr"></span> 
                    </div>
                </div>
                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">机具备案: </label>

                    <div class="col-sm-9">
                        <input type="text" name="machines_record" class="col-xs-10 col-sm-5" id="machines" onBlur="checkmachines()" oninput="checkmachines()"/>
                        <span class="default" id="machinesErr"></span> 
                    </div>
                </div>

                <div class="space-4"></div>


                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">劳务分包内容: </label>

                    <div class="col-sm-9">
                        <input type="text" name="labor_subcontract" class="col-xs-10 col-sm-5" id="subcontract" onBlur="checksubcontract()" oninput="checksubcontract()"/>
                        <span class="default" id="subcontractErr"></span> 
                    </div>
                </div>
                <div class="space-4"></div>

                <!--<div class="clearfix form-actions">-->

                <div >
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="submit">
                            <i class="icon-ok bigger-110"></i>
                            提交
                        </button>

                        &nbsp; &nbsp; &nbsp;
                        <button class="btn" type="reset">
                            <i class="icon-undo bigger-110"></i>
                            重置
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>

</div>
<script type="text/javascript"> 
    function checkForm(){ 
        var nametip = checkUserName(); 
        var requirement = checkteam();  
        var content = checknum(); 
        var logging = checkspecial(); 
        var machines = checkmachines();
        var subcontract = checksubcontract();
        return nametip && requirement && content && logging && machines && subcontract;
    } 
    
    function checkUserName(){ 
        var username = document.getElementById('project_name'); 
        var errname = document.getElementById('nameErr'); 
        var pattern = /^[A-Za-z0-9\u4e00-\u9fa5]{2,20}$/;
        if(username.value.length == 0){ 
            errname.innerHTML="项目名称不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="项目名称不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    } 

    function checkteam(){ 
        var username = document.getElementById('team'); 
        var errname = document.getElementById('teamErr');
        var pattern = /^[A-Za-z0-9\u4e00-\u9fa5]{2,20}$/;
        if(username.value.length == 0){ 
            errname.innerHTML="劳务队名称不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="劳务队名称不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

    function checknum(){ 
        var username = document.getElementById('num'); 
        var errname = document.getElementById('numErr'); 
        var pattern = /^\d+$/;
        if(username.value.length == 0){ 
            errname.innerHTML="劳务队人数不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="劳务队人数不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

    function checkspecial(){ 
        var username = document.getElementById('special'); 
        var errname = document.getElementById('specialErr'); 
        var pattern = /^\d+$/;
        if(username.value.length == 0){ 
            errname.innerHTML="特种人员数量不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="特种人员数量不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

    function checkmachines(){ 
        var username = document.getElementById('machines'); 
        var errname = document.getElementById('machinesErr');
        var pattern = /^[A-Za-z0-9\u4e00-\u9fa5,，。、/]+$/; 
        if(username.value.length == 0){ 
            errname.innerHTML="机具备案不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="机具备案不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

    function checksubcontract(){ 
        var username = document.getElementById('subcontract'); 
        var errname = document.getElementById('subcontractErr'); 
        var pattern = /^[A-Za-z0-9\u4e00-\u9fa5,，。、/]+$/; 
        if(username.value.length == 0){ 
            errname.innerHTML="劳务分包不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="劳务分包不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

</script>
{/block}